import os
import configparser

class ConfigReader:
    """配置文件工具类"""

    def __init__(self):
        self.config = configparser.ConfigParser()
        self.config_path = os.path.join("config", "config.ini")

    def get_value(self, section: str, key: str, fallback: str = ""): # fallback 默认返回值
        """获取配置项的值"""
        try:
            if not os.path.exists(self.config_path):
                return fallback
            
            self.config.read(self.config_path, encoding="utf-8")
            return self.config.get(section, key, fallback=fallback)
        except Exception:
            return fallback
